﻿<?php
if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

	if(date("m")==1)
	{
		$last_month=12;
		$year=date("Y")-1;
	}
	else
	{
		$last_month=date("m")-1;
		$year=date("Y");
	}
$query = $db->query("SELECT COUNT(*) AS cnt, uid AS authorid FROM {$tablepre}stars WHERE  MONTH(time)=$last_month AND YEAR(time)=$year AND type=1 GROUP BY authorid ORDER BY cnt DESC");
$rs = $db->fetch_array($query);
$cnt=(int)$rs['cnt'];//今日之星天数数
$uid=(int)$rs['authorid'];//用户uid


$db->query("INSERT INTO {$tablepre}stars (type,uid,cnt) VALUES (2, $uid,$cnt)");



?>